package cn.lili.modules.goods.serviceimpl;

import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.DutyFreeFAQ;
import cn.lili.modules.goods.mapper.DutyFreeFAQMapper;
import cn.lili.modules.goods.service.DutyFreeFAQService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class DutyFreeFAQServiceImpl extends ServiceImpl<DutyFreeFAQMapper, DutyFreeFAQ>
        implements DutyFreeFAQService {

    /**
     * 分页查询
     * @param dutyFreeFAQ
     * @param pageVO
     * @return
     */
    @Override
    public Page<DutyFreeFAQ> getByPage (DutyFreeFAQ dutyFreeFAQ, PageVO pageVO) {
        LambdaQueryWrapper<DutyFreeFAQ> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(dutyFreeFAQ.getQuestion()), DutyFreeFAQ::getQuestion, dutyFreeFAQ.getQuestion());
        queryWrapper.like(StringUtils.isNotEmpty(dutyFreeFAQ.getAnswer()), DutyFreeFAQ::getAnswer, dutyFreeFAQ.getAnswer());
        queryWrapper.orderByDesc(DutyFreeFAQ::getSortNo);
        return this.page(PageUtil.initPage(pageVO), queryWrapper);
    }
}
